package com.example.demo.study.controller;

import com.example.demo.study.pojo.SysUser;
import com.example.demo.study.service.SysUserService;
import com.example.demo.study.utils.ResponseResult;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;

/**
 * @author leo
 * @Date 2023/11/8 22:25
 * @Version 1.0
 */
@RestController
public class SysUserController {

    @Autowired
    private SysUserService sysUserService;


    public void  BCryptPasswordEncoder(){
        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
        String encode = passwordEncoder.encode(  "1234");
        String encode2 = passwordEncoder.encode(  "1234");
        System. out.println(encode);
        System.out.println(encode2);

    }

//    public static void main(String[] args) {
//        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
//        String encode = passwordEncoder.encode(  "1234");
//        String encode2 = passwordEncoder.encode(  "1234");
//        System. out.println(encode);
//        System.out.println(encode2);
//    }

    @GetMapping(value = "/user/get")
    public SysUser get(@Param("id") String id){
        return sysUserService.get(id);
    }
    @PostMapping(value = "/user/login")
    public ResponseResult login(@RequestBody SysUser sysUser){
        return sysUserService.login(sysUser);
    }

    @PostMapping(value = "/user/logout")
    public ResponseResult logout(){
        return sysUserService.logout();
    }


}
